home *** CD-ROM | disk | FTP | other *** search
- Path: news.Stanford.EDU!not-for-mail
- From: iburrell@leland.Stanford.EDU (Ian Burrell)
- Newsgroups: comp.lang.c++,gnu.g++.help
- Subject: Forward declarations of typedefs
- Date: 28 Feb 1996 12:56:25 -0800
- Organization: Stanford University
- Message-ID: <4h2fhp$si8@elaine22.Stanford.EDU>
- NNTP-Posting-Host: elaine22.stanford.edu
-
- I am trying to do a forward declaration of a type defined in another
- header so that I can make a class member that is a pointer. However,
- if the forward declaration type is later defined as a typedef, I get
- lots of errors.
-
- Is there a way to consistently make forward declarations that works
- with later typedefs? Does the method work if the type representation
- later changes? How about anonymous structs defined in a typedef?
-
- Here is a snippet of example code and the errors it gives:
-
- struct test;
-
- test* t;
-
- struct _test
- {
- int a;
- };
-
- typedef _test test;
-
- typedef.cc:15: conflicting types for `struct _test'
- typedef.cc:15: previous declaration as `struct test'
- typedef.cc: In function `int main()':
- typedef.cc:20: type `test' is not a base type for type `_test'
- typedef.cc:21: invalid use of undefined type `struct test'
- typedef.cc:23: invalid use of undefined type `struct test'
-
-
- - Ian
-
-
- --
- -- Ian Burrell == iburrell@leland.stanford.edu **
- <URL:http://www-leland.stanford.edu/~iburrell/>
- Zymurgy's Law of Volunteer Labor:
- People are always available for work in the past tense.
-